#import "dfhgwhruebvhrheyadmitultimate.h"
#import "dfhgwhruebvhrheydiscourageconstituent.h"
#import "dfhgwhruebvhrheyfantasyviolinViewController.h"
@interface dfhgwhruebvhrheydiscourageconstituent ()
@property (nonatomic, strong) dfhgwhruebvhrheyadmitultimate *homeModel;
@property (weak, nonatomic) IBOutlet UILabel *tipsText;
@property (weak, nonatomic) IBOutlet UIButton *applyBtn;
@property (weak, nonatomic) IBOutlet UILabel *statusText;
@property (weak, nonatomic) IBOutlet UILabel *amountText;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *statusTextHeight;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *tipsTextHeight;
@end
@implementation dfhgwhruebvhrheydiscourageconstituent {
	void(^_callback)(void);
}
- (void)bindData:(dfhgwhruebvhrheyadmitultimate *)model andCallBack:(void(^)(void))callback {
	_callback = callback;
	self.homeModel = model;
    self.amountText.text = [NSString stringWithFormat:@"PHP %@", model.max_money.dhgfywegwygeydwlocalitylearned];
	if (model.status == 3) {
        self.statusText.text = @"Congrats!";
        self.statusTextHeight.constant = 33;
        self.statusText.textColor = text_color6.dhgfywegwygeydwlearneddesignate;
        [self.applyBtn setTitle:@"Apply for withdrawal" forState:UIControlStateNormal];
        self.tipsText.text = @"Your application has been approved,please confirm your loan amount and repayment deadline,and get your loan immediately!";
        CGSize size = [self.tipsText sizeThatFits:CGSizeMake(dhgfywegwygeydwdispositionvisualize - 60 - 28, CGFLOAT_MAX)];
        self.tipsTextHeight.constant = size.height + 5;
    }else if (model.status == 5) {
        self.statusText.text = @"Paying!";
        self.statusTextHeight.constant = 33;
        self.statusText.textColor = text_color2.dhgfywegwygeydwlearneddesignate;
        [self.applyBtn setTitle:@"5 star comment for accelerated review" forState:UIControlStateNormal];
        self.tipsText.text = @"The system is on the remittance,please wait patiently. If the payment fails,you can log in the APP to apply for re-remit";
        CGSize size = [self.tipsText sizeThatFits:CGSizeMake(dhgfywegwygeydwdispositionvisualize - 60 - 28, CGFLOAT_MAX)];
        self.tipsTextHeight.constant = size.height + 5;
    }else if (model.status == 6) {
        self.statusText.text = @"Repayment successful!";
        self.statusTextHeight.constant = 33;
        self.statusText.textColor = text_color6.dhgfywegwygeydwlearneddesignate;
        [self.applyBtn setTitle:@"Reloan Now" forState:UIControlStateNormal];
        self.tipsText.text = @"Keep your credit good and you can get a higher loan amount and a longer loan term if you borrow again.";
        CGSize size = [self.tipsText sizeThatFits:CGSizeMake(dhgfywegwygeydwdispositionvisualize - 60 - 28, CGFLOAT_MAX)];
        self.tipsTextHeight.constant = size.height + 5;
	}else {
        self.statusText.text = @"Warning Sign!";
        self.statusTextHeight.constant = 33;
        self.statusText.textColor = text_color5.dhgfywegwygeydwlearneddesignate;
        [self.applyBtn setTitle:@"Re-withdrawal" forState:UIControlStateNormal];
        self.tipsText.text = @"The payment system appears the unusual, you may choose the withdrawal way to carry on the withdrawal,very sorry brings the inconvenience you!";
        CGSize size = [self.tipsText sizeThatFits:CGSizeMake(dhgfywegwygeydwdispositionvisualize - 60 - 28, CGFLOAT_MAX)];
        self.tipsTextHeight.constant = size.height + 5;
	}
}
- (IBAction)withdrawalBtnClick:(UIButton *)sender {
	if (self.homeModel.status == 5) {
		NSLog(@"打款中，五星好评");
		NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id%@?action=write-review", APPID]];
		if([[UIApplication sharedApplication] canOpenURL:url]) {
			[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
		}
	}else if (self.homeModel.status == 6) {
		if (_callback) {
			_callback();
		}
	}else {
		NSLog(@"去借款");
		dfhgwhruebvhrheyfantasyviolinViewController *loan = (dfhgwhruebvhrheyfantasyviolinViewController *)[UIStoryboard storyboard:@"Home" withidentifier:@"loan"];
		loan.hidesBottomBarWhenPushed = YES;
		[self.controller.navigationController pushViewController:loan animated:YES];
	}
}
@end
